home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
qwik30.arc
/
QWRITES.INC
< prev
next >
Wrap
Text File
|
1987-08-31
|
17KB
|
241 lines
{ Qwrites.inc - QwriteLV, QwriteV, Qwrite, QwriteC, QwriteCV v 3.0, 08-31-87 }
{ These five procedures do fast screen writes and automatically configure to
any IBM adapter card. They also have the feature of leaving the attribute
alone by setting Attr<0; then they will just overwrite the display using
the current attributes. The upper left column is 1,1.
Read MODIFICATIONS in QWIK21.DOC for possible changes in this file. }
{ QwritesDisp - Subroutine for all QwriteXX procedures ver 3.0, 08-31-87 }
procedure QwritesDisp;
begin
Inline( {Assembly by Inline 08/16/87 19:48}
$4A/ { dec dx ;Convert to 0-?? range}
$88/$E6/ { mov dh,ah ;Save St[1] in DH}
$31/$C0/ { xor ax,ax ;Set AX=0}
$8E/$C0/ { mov es,ax ;Set ES=0}
$26/ { es: ;Segment override}
$A1/$4A/$04/ { mov ax,[$044A] ;Get CRT columns}
$F6/$E2/ { mul dl ;(CRT columns)*(Row-1)}
$D1/$E0/ { shl ax,1 ;Mult by 2}
$01/$C7/ { add di,ax ;Dest offset in DI}
$88/$DC/ { mov ah,bl ;Move attr to AH}
$88/$F0/ { mov al,dh ;Move St[1] to AL}
$8E/$46/$FC/ { mov es,[bp-$04] ;Copy DS in ES}
$26/ { es: ;Segment override}
$80/$3E/>QWAIT/$00/ { cmp by[>Qwait],$00 ;Check need for wait}
$26/ { es: ;Segment override}
$8E/$06/>QSEG/ { mov es,[>Qseg] ;ES:DI dest pointer}
$75/$32/ { jne Color ; use Color routine}
{ ;}
$84/$FF/ { test bh,bh ;If Attr<0 ...}
$78/$16/ { js Mono1 ; use char only}
{ ;}
{; -- Mono routine; Attr, Char and No Wait--}
{; Algorithm packs in an extra STOSW per LOOP}
$41/ {Mono2: inc cx ;Bump CX for odd char}
$D1/$E9/ { shr cx,1 ;Divide counter by 2}
{ ; CF=0 if odd length}
$EB/$08/ { jmp SHORT Mon2b ;Jump into mono loop}
{ ;}
$AD/ {Mon2a: lodsw ;Load TWO char}
$88/$E7/ { mov bh,ah ;Move Ch2 to BH}
$88/$DC/ { mov ah,bl ;Copy attr to AH}
$AB/ { stosw ;To dest & inc DI 2}
$88/$F8/ { mov al,bh ;Move Ch2 to AL}
$AB/ {Mon2b: stosw ;To dest & inc DI 2}
$E2/$F5/ { loop Mon2a ;Loop until CX=0}
$73/$6C/ { jnc Done ;Exit if odd length}
$AC/ { lodsb ;Load last char}
$AB/ { stosw ;To dest & inc DI 2}
$EB/$68/ { jmp SHORT Done ;Done}
{ ;}
{; -- Mono routine; Char Only and No Wait--}
{; Algorithm packs in an extra STOSB per LOOP}
$41/ {Mono1: inc cx ;Bump CX for odd char}
$89/$CA/ { mov dx,cx ;Save CX in DX}
$D1/$E9/ { shr cx,1 ;Divide counter by 2}
$EB/$05/ { jmp SHORT Mon1b ;Jump into mono loop}
{ ;}
$AD/ {Mon1a: lodsw ;Load TWO char}
$AA/ { stosb ;To dest & inc DI 1}
$47/ { inc di ;Pass up attr}
$88/$E0/ { mov al,ah ;Move Ch2 to AL}
$AA/ {Mon1b: stosb ;To dest & inc DI 1}
$47/ { inc di ;Pass up attr}
$E2/$F7/ { loop Mon1a ;Loop until CX=0}
$D1/$EA/ { shr dx,1 ;Divide counter by 2}
{ ;CF=0 if odd length}
$73/$54/ { jnc Done ;Exit if odd length}
$AC/ { lodsb ;Load last char}
$AA/ { stosb ;To dest & inc DI 1}
$EB/$50/ { jmp SHORT Done ;Done}
{ ;}
$BA/$DA/$03/ {Color: mov dx,$03DA ;CGA port}
$84/$FF/ { test bh,bh ;If Attr<0 ...}
$78/$29/ { js Col1b ; use char only}
$88/$DC/ { mov ah,bl ;Move attr in AH}
$EB/$01/ { jmp SHORT Col2b ;Attr and char}
{ ;}
{; -- Color routine; Attr, Char and Wait --}
$AC/ {Col2a: lodsb ;Load source char}
$88/$C7/ {Col2b: mov bh,al ;Save char in BH}
$FA/ { cli ;Disable interrupts}
$EC/ {E4in2: in al,dx ;Check CGA status}
$A8/$08/ { test al,$08 ;If #3 bit clear ...}
$74/$09/ { jz Col2c ; check #0 bit.}
$88/$F8/ { mov al,bh ;Move char back in AL}
$80/$F9/$90/ { cmp cl,$90 ;If <145 Cols left,}
$78/$B7/ { js Mono2 ; do mono instead}
$EB/$0B/ { jmp SHORT Col2d ; else store direct}
$D0/$D8/ {Col2c: rcr al,1 ;If #0 bit set ...}
$72/$EE/ { jc E4in2 ; try again for $E4}
$EC/ {E5in2: in al,dx ;Check CGA status}
$D0/$D8/ { rcr al,1 ;If #0 bit clear ...}
$73/$FB/ { jnc E5in2 ; try again for $E5}
$88/$F8/ { mov al,bh ;Move char back in AL}
$AB/ {Col2d: stosw ;Put in dest & inc DI}
$FB/ { sti ;Enable interrupts}
$E2/$DF/ { loop Col2a ;Loop till CX=0}
$EB/$22/ { jmp SHORT Done ;Done}
{ ;}
{; -- Color routine; Char only and Wait --}
$AC/ {Col1a: lodsb ;Load source char}
$47/ { inc di ;Pass up attr}
$88/$C7/ {Col1b: mov bh,al ;Save char in BH}
$FA/ { cli ;Disable interrupts}
$EC/ {E4in1: in al,dx ;Check CGA status}
$A8/$08/ { test al,$08 ;If #3 bit clear ...}
$74/$09/ { jz Col1c ; check #0 bit.}
$88/$F8/ { mov al,bh ;Move char back in AL}
$80/$F9/$80/ { cmp cl,$80 ;If <129 Cols left,}
$78/$A9/ { js Mono1 ; do mono instead.}
$EB/$0B/ { jmp SHORT Col1d ; else store direct}
$D0/$D8/ {Col1c: rcr al,1 ;If #0 bit set ...}
$72/$EE/ { jc E4in1 ; try again for $E4}
$EC/ {E5in1: in al,dx ;Check CGA status}
$D0/$D8/ { rcr al,1 ;If #0 bit clear ...}
$73/$FB/ { jnc E5in1 ; try again for $E5}
$88/$F8/ { mov al,bh ;Move char back in AL}
$AA/ {Col1d: stosb ;Put in dest & inc DI}
$FB/ { sti ;Enable interrupts}
$E2/$DE/ { loop Col1a ;Loop till CX=0}
{ ;}
$FB/ {Done: sti ;Enable interrupts}
$C3); { ret ;Return to call}
end;
{ QwriteLV - Quick screen write, specified Length, untyped VAR parameter }
{ ver 3.0, 08-31-87 }
{ Unlike other QwriteXX procedures, this one lets you specify both Length and }
{ starting index for partial strings. All other procedures assume length is }
{ the value in St[0] and the index points to St[1]. }
procedure QwriteLV (Row, Col: byte; Attr, Length: integer; VAR St);
begin
Inline( {Assembly by Inline 08/16/87 19:48}
$8B/$4E/<LENGTH/ { mov cx,[bp+<Length] ;Move length in CX}
$85/$C9/ { test cx,cx ;If CX<=0,}
$7E/$18/ { jle exit ; nothing to do.}
$1E/ { push ds ;Save Turbo's DS}
$C5/$76/<ST/ { lds si,[bp+<St] ;Place offset in SI}
$FC/ { cld ;Set DF to increment}
$AC/ { lodsb ;Load St[i]}
$88/$C4/ { mov ah,al ;Move St[i] to AH}
$8B/$56/<ROW/ { mov dx,[bp+<Row] ;Move row in DX}
$8B/$7E/<COL/ { mov di,[bp+<Col] ;Move col in DI}
$4F/ { dec di ;Convert to 0-?? range}
$D1/$E7/ { shl di,1 ;Mult by 2}
$8B/$5E/<ATTR/ { mov bx,[bp+<Attr] ;Move attr in BX}
$E8/>QWRITESDISP-*+5/ { call >QwritesDisp-*+5 ;Call QwritesDisp}
$1F { pop ds ;Restore Turbo's DS}
); {Exit: ;}
end;
{ QwriteV - Quick screen write, untyped VAR parameter ver 3.0, 08-31-87 }
procedure QwriteV (Row, Col: byte; Attr: integer; VAR St);
begin
Inline( {Assembly by Inline 08/16/87 19:48}
$1E/ { push ds ;Save Turbo's DS}
$C5/$76/<ST/ { lds si,[bp+<St] ;Place offset in SI}
$FC/ { cld ;Set DF to increment}
$AD/ { lodsw ;Load St[1],St[0]}
$31/$C9/ { xor cx,cx ;Set CX=0}
$00/$C1/ { add cl,al ;Save length in CL}
$74/$0F/ { jz Exit ;Null string}
$8B/$56/<ROW/ { mov dx,[bp+<Row] ;Move row in DX}
$8B/$7E/<COL/ { mov di,[bp+<Col] ;Move col in DI}
$4F/ { dec di ;Convert to 0-?? range}
$D1/$E7/ { shl di,1 ;Mult by 2}
$8B/$5E/<ATTR/ { mov bx,[bp+<Attr] ;Move attr}
$E8/>QWRITESDISP-*+5/ { call >QwritesDisp-*+5 ;Call QwritesDisp}
$1F); {Exit: pop ds ;Restore Turbo's DS}
end;
{ Qwrite - Quick screen write, value parameter ver 3.0, 08-31-87 }
procedure Qwrite (Row, Col: byte; Attr: integer; St: Str80);
begin
Inline( {Assembly by Inline 08/16/87 19:48}
$1E/ { push ds ;Save Turbo's DS}
$8D/$B6/>ST/ { lea si,[bp+>St] ;Place offset in SI}
$8C/$D2/ { mov dx,ss ;Move SS into DS for}
$8E/$DA/ { mov ds,dx ; use by LODS}
$FC/ { cld ;Set DF to increment}
$AD/ { lodsw ;Load St[1],St[0]}
$31/$C9/ { xor cx,cx ;Set CX=0}
$00/$C1/ { add cl,al ;Save length in CL}
$74/$12/ { jz Exit ;Null string}
$8B/$96/>ROW/ { mov dx,[bp+>Row] ;Move row in DX}
$8B/$BE/>COL/ { mov di,[bp+>Col] ;Move col in DI}
$4F/ { dec di ;Convert to 0-?? range}
$D1/$E7/ { shl di,1 ;Mult by 2}
$8B/$9E/>ATTR/ { mov bx,[bp+>Attr] ;Move attr}
$E8/>QWRITESDISP-*+5/ { call >QwritesDisp-*+5 ;Call QwritesDisp}
$1F); {Exit: pop ds ;Restore Turbo's DS}
end;
{ QwriteC - Quick screen write, self-centering, value param v 3.0, 08-31-87 }
procedure QwriteC (Row, ColL, ColR: byte; Attr: integer; St: Str80);
begin
Inline( {Assembly by Inline 08/16/87 19:48}
$1E/ { push ds ;Save Turbo's DS}
$8D/$B6/>ST/ { lea si,[bp+>St] ;Place offset in SI}
$8C/$D2/ { mov dx,ss ;Move SS into DS for}
$8E/$DA/ { mov ds,dx ; use by LODS}
$FC/ { cld ;Set DF to increment}
$AD/ { lodsw ;Load St[1],St[0]}
$31/$C9/ { xor cx,cx ;Set CX=0}
$00/$C1/ { add cl,al ;Save length in CL}
$74/$1A/ { jz Exit ;Null string}
$8B/$96/>ROW/ { mov dx,[bp+>Row] ;Move row in DX}
$8B/$BE/>COLL/ { mov di,[bp+>ColL] ;Move col in DI}
$03/$BE/>COLR/ { add di,[bp+>ColR] ;Add right col}
$4F/ { dec di ;Convert to 0-?? range}
$29/$CF/ { sub di,cx ;Offset calc'd in DI}
$81/$E7/$FE/$FF/ { and di,$FFFE ;Make even}
$8B/$9E/>ATTR/ { mov bx,[bp+>Attr] ;Move attr}
$E8/>QWRITESDISP-*+5/ { call >QwritesDisp-*+5 ;Call QwritesDisp}
$1F); {Exit: pop ds ;Restore Turbo's DS}
end;
{ QwriteCV - Quick screen write, self-centering, untyped VAR parameter
ver 3.0, 08-31-87 }
procedure QwriteCV (Row, ColL, ColR: byte; Attr: integer; VAR St);
begin
Inline( {Assembly by Inline 08/16/87 19:48}
$1E/ { push ds ;Save Turbo's DS}
$C5/$76/<ST/ { lds si,[bp+<St] ;Place offset in SI}
$FC/ { cld ;Set DF to increment}
$AD/ { lodsw ;Load St[1],St[0]}
$31/$C9/ { xor cx,cx ;Set CX=0}
$00/$C1/ { add cl,al ;Save length in CL}
$74/$16/ { jz Exit ;Null string}
$8B/$56/<ROW/ { mov dx,[bp+<Row] ;Move row in DX}
$8B/$7E/<COLL/ { mov di,[bp+<ColL] ;Move col in DI}
$03/$7E/<COLR/ { add di,[bp+<ColR] ;Add right col}
$4F/ { dec di ;Convert to 0-?? range}
$29/$CF/ { sub di,cx ;Offset calc'd in DI}
$81/$E7/$FE/$FF/ { and di,$FFFE ;Make even}
$8B/$5E/<ATTR/ { mov bx,[bp+<Attr] ;Move attr}
$E8/>QWRITESDISP-*+5/ { call >QwritesDisp-*+5 ;Call QwritesDisp}
$1F); {Exit: pop ds ;Restore Turbo's DS}
end;